package com.yzy.controller;

import com.yzy.dao.DoctorDao;
import com.yzy.dao.PatientDao;
import com.yzy.entity.Doctors;
import com.yzy.entity.Patients;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;

@WebServlet(name = "PatientFindServlet")
public class PatientFindServlet extends HttpServlet {


    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {

        PatientDao dao= new PatientDao();
        PrintWriter out;
        //1用户信息用【list】
        List<Patients> patientList = dao.findAll();
        //2
        response.setContentType("text/html;charset=utf-8");
        out=response.getWriter();
        out.print("<table boder='2' align='center'>");
        out.print("<tr>");
        out.print("<td>患者手机号</td>");
        out.print("<td>患者姓名</td>");
        out.print("<td>患者年龄</td>");
        out.print("<td>患者病史</td>");
        out.print("<td>患者密码</td>");
        out.print("<td>患者性别</td>");
        out.print("</tr>");

        for(Patients patient : patientList){
            out.print("<tr>");
            out.print("<td>"+patient.getPphone()+"</td>");
            out.print("<td>"+patient.getPname()+"</td>");
            out.print("<td>"+patient.getPage()+"</td>");
            out.print("<td>"+patient.getHistory()+"</td>");
            out.print("<td>"+"******"+"</td>");
            out.print("<td>"+patient.getPsex()+"</td>");
            out.print("</tr>");
        }
        out.print("</table>");


    }
}
